import {findVideo} from "../api";

export const mixin={
    //namespaced:true,
    methods:{
        //提示信息
        notify(title,type){
            this.$notify({
                title:title,
                type:type
            })
        },
        //获取图片
        attachImageUrl(srcUrl){
            return srcUrl? this.$store.state.configure.photoUrl+srcUrl : 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F6d84060bdff92fad071278ec9aa72b52aac49ac2b3ff-Ba8AUJ_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1628216533&t=47b97b1337f35c0e56ba40fbe8320f75';
        },
        //搜索
        getVideo(){

            if(!this.$route.query.keywords){
                this.$store.commit('setListOfVideos',[]);
                this.notify('null','warning')
            }else{
                findVideo(this.$route.query.keywords).then(res =>{
                    if (!res.length){
                        this.$store.commit('setListOfVideos',[]);
                        this.notify('系统暂无符合条件视频','warning');
                    }else {
                        console.log(this.$route.query.keywords)
                        this.$store.commit('setListOfVideos',res);
                        this.notify('success','success');
                    }
                }).catch(err=>{
                    console.log(err)
                })

            }
        }
    }
}